<?php 
/**
 * 
 * 用户头像列表，带收听按钮，默认3个一组
 * 传入参数
 * $avatars = array(
 * 		"perline"=>3,
 * 		"info"=>array(
 * 			array(
 * 				"name"=>"xxx",
 * 				"nick"=>"xxx",
 * 				"head"=>"xxx",
 * 				"ismyidol"=>true
 * 			)
 * 		)
 * )
 */
?>
<?php 
	$numberline = 3;
	if( array_key_exists( "perline",$avatars ) && !empty($avatars["perline"]) ){
		$numberline = $avatars["perline"];
	}
	if( $numberline != 3 ){
		echo "<style>";
		echo ".avatars ul.avatargroup li{width:".intval(100/$numberline)."%;}";
		echo "</style>";
	}
?>
<?php
	
	if($avatars["info"]) {
		$avatars_chunks = array_chunk( $avatars["info"], $numberline );
		echo "<div class=\"avatars\">";
		foreach($avatars_chunks as $avatar_grp){
			echo "<ul class=\"avatargroup\">";
			foreach($avatar_grp as $avatar){
				echo "<li>";
				echo "<a class=\"avatar\" href=\"./index.php?m=guest&u=".$avatar["name"]."\" title=\"".$avatar["nick"]."(@".$avatar["name"].")\"><img src=\"".(empty($avatar["head"])?"./style/images/default_head_small.png":$avatar["head"])."\"></img></a>";
				echo "<a class=\"nick\" href=\"./index.php?m=guest&u=".$avatar["name"]."\">".$avatar["nick"]."</a>";
				if(array_key_exists("ismyidol", $avatar)){
					echo "<a class=\"flowactionsmall usebtns ".($avatar["ismyidol"] ? "quxiao":"shouting")."\" href=\"javascript:;\" data-username=\"".$avatar["name"]."\"></a>";
				}
				echo "</li>";
			}
			echo "</ul>";
		}
		echo "</div>";
	}

?>